<template>
	<view class="content">
		<view class="title">
			子组件B
		</view>
		<view class="b-box">
			comA组件传进来的值:
			<text class="intent-text-box">{{result}}</text>
		</view>
		<view class="b-box" style="margin: 10rpx;">
			<text>回传值:</text>
			<input type="text" v-model="callbackValue" style="color: black;" />
			<button @click="sendOutside()" size="mini">回传</button>
		</view>
	</view>
</template>

<script>
	export default {
		name: "comB",
		props: ['result'],
		data() {
			return {
				callbackValue: ''
			};
		},
		methods: {
			sendOutside() {
				console.warn("---CompB---sendOutside---" + this.callbackValue);
				this.$emit('xxx', this.callbackValue);
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #34cd72;
		padding: 30rpx;
		border-radius: 12rpx;
	}

	.title {
		font-size: 50rpx;
		font-weight: bold;
		margin-bottom: 20rpx;
	}

	.b-box {
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
		width: 100%;
	}

	.b-box text {
		margin-right: 10rpx;
		font-size: 32rpx;
	}

	.intent-text-box {
		background-color: #007aff;
		color: #fff;
		padding: 6rpx 12rpx;
		border-radius: 6rpx;
		flex: 1;
	}

	input {
		border: 1rpx solid #ccc;
		padding: 10rpx;
		border-radius: 8rpx;
		margin-right: 10rpx;
		flex: 1;
	}
</style>